// Copyright (c) 2022 Presto Labs Pte. Ltd.
// Author: qiang

#include <map>
#include <mutex>
#include <string>
#include <vector>
namespace coin2::exchange::gdax::api_order {

class GdaxTransfersAccountStore {
 public:
  bool is_initialized() { return is_initialized_; }

  const std::map<std::string, std::string>& GetCurrencyIdMap() { return currency_id_store_map_; }

  void SetCurrencyIdMap(std::map<std::string, std::string>& currency_id_map) {
    if (is_initialized_) {
      return;
    }
    std::unique_lock<std::mutex> lock(mutex_);
    if (is_initialized_) {
      return;
    }
    currency_id_store_map_ = std::move(currency_id_map);
    is_initialized_ = true;
  }

  static GdaxTransfersAccountStore& GetInstance() {
    static GdaxTransfersAccountStore instance;
    return instance;
  }

 private:
  GdaxTransfersAccountStore(const GdaxTransfersAccountStore&) = delete;
  GdaxTransfersAccountStore() = default;
  GdaxTransfersAccountStore& operator=(const GdaxTransfersAccountStore&) = delete;

 private:
  bool is_initialized_ = false;
  std::map<std::string, std::string> currency_id_store_map_;
  std::mutex mutex_;
};

}  // namespace coin2::exchange::gdax::api_order